<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>relative.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
  </script>

  <script src="static/js/doc.js">
  </script>

  <meta charset="utf8">
</head>

<body onload="prettyPrint()">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="closure_goog_date_relative.js.html">relative.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line2"></a>// you may not use this file except in compliance with the License.
<a name="line3"></a>// You may obtain a copy of the License at
<a name="line4"></a>//
<a name="line5"></a>//     http://www.apache.org/licenses/LICENSE-2.0
<a name="line6"></a>//
<a name="line7"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line8"></a>// distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
<a name="line9"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line10"></a>// See the License for the specific language governing permissions and
<a name="line11"></a>// limitations under the License.
<a name="line12"></a>
<a name="line13"></a>// Copyright 2009 Google Inc. All Rights Reserved.
<a name="line14"></a>
<a name="line15"></a>/**
<a name="line16"></a> * @fileoverview Functions for formatting relative dates.  Such as &quot;3 days ago&quot;
<a name="line17"></a> * &quot;3 hours ago&quot;, &quot;14 minutes ago&quot;, &quot;12 days ago&quot;, &quot;Today&quot;, &quot;Yesterday&quot;.
<a name="line18"></a> *
<a name="line19"></a> */
<a name="line20"></a>
<a name="line21"></a>goog.provide(&#39;goog.date.relative&#39;);
<a name="line22"></a>
<a name="line23"></a>goog.require(&#39;goog.i18n.DateTimeFormat&#39;);
<a name="line24"></a>
<a name="line25"></a>
<a name="line26"></a>/**
<a name="line27"></a> * Number of milliseconds in a minute.
<a name="line28"></a> * @type {number}
<a name="line29"></a> * @private
<a name="line30"></a> */
<a name="line31"></a>goog.date.relative.MINUTE_MS_ = 60000;
<a name="line32"></a>
<a name="line33"></a>
<a name="line34"></a>/**
<a name="line35"></a> * Number of milliseconds in a day.
<a name="line36"></a> * @type {number}
<a name="line37"></a> * @private
<a name="line38"></a> */
<a name="line39"></a>goog.date.relative.DAY_MS_ = 86400000;
<a name="line40"></a>
<a name="line41"></a>
<a name="line42"></a>/**
<a name="line43"></a> * Enumeration used to identify time units internally.
<a name="line44"></a> * @enum {number}
<a name="line45"></a> * @private
<a name="line46"></a> */
<a name="line47"></a>goog.date.relative.Unit_ = {
<a name="line48"></a>  MINUTES: 0,
<a name="line49"></a>  HOURS: 1,
<a name="line50"></a>  DAYS: 2
<a name="line51"></a>};
<a name="line52"></a>
<a name="line53"></a>
<a name="line54"></a>/**
<a name="line55"></a> * Full date formatter.
<a name="line56"></a> * @type {goog.i18n.DateTimeFormat}
<a name="line57"></a> * @private
<a name="line58"></a> */
<a name="line59"></a>goog.date.relative.fullDateFormatter_;
<a name="line60"></a>
<a name="line61"></a>
<a name="line62"></a>/**
<a name="line63"></a> * Short time formatter.
<a name="line64"></a> * @type {goog.i18n.DateTimeFormat}
<a name="line65"></a> * @private
<a name="line66"></a> */
<a name="line67"></a>goog.date.relative.shortTimeFormatter_;
<a name="line68"></a>
<a name="line69"></a>
<a name="line70"></a>/**
<a name="line71"></a> * Month-date formatter.
<a name="line72"></a> * @type {goog.i18n.DateTimeFormat}
<a name="line73"></a> * @private
<a name="line74"></a> */
<a name="line75"></a>goog.date.relative.monthDateFormatter_;
<a name="line76"></a>
<a name="line77"></a>
<a name="line78"></a>/**
<a name="line79"></a> * Returns a date in month format, e.g. Mar 15.
<a name="line80"></a> * @param {Date} date The date object.
<a name="line81"></a> * @return {string} The formatted string.
<a name="line82"></a> * @private
<a name="line83"></a> */
<a name="line84"></a>goog.date.relative.formatMonth_ = function(date) {
<a name="line85"></a>  if (!goog.date.relative.monthDateFormatter_) {
<a name="line86"></a>    goog.date.relative.monthDateFormatter_ =
<a name="line87"></a>        new goog.i18n.DateTimeFormat(&#39;MMM dd&#39;);
<a name="line88"></a>  }
<a name="line89"></a>  return goog.date.relative.monthDateFormatter_.format(date);
<a name="line90"></a>};
<a name="line91"></a>
<a name="line92"></a>
<a name="line93"></a>/**
<a name="line94"></a> * Returns a date in short-time format, e.g. 2:50 PM.
<a name="line95"></a> * @param {Date} date The date object.
<a name="line96"></a> * @return {string} The formatted string.
<a name="line97"></a> * @private
<a name="line98"></a> */
<a name="line99"></a>goog.date.relative.formatShortTime_ = function(date) {
<a name="line100"></a>  if (!goog.date.relative.shortTimeFormatter_) {
<a name="line101"></a>    goog.date.relative.shortTimeFormatter_ = new goog.i18n.DateTimeFormat(
<a name="line102"></a>        goog.i18n.DateTimeFormat.Format.SHORT_TIME);
<a name="line103"></a>  }
<a name="line104"></a>  return goog.date.relative.shortTimeFormatter_.format(date);
<a name="line105"></a>};
<a name="line106"></a>
<a name="line107"></a>
<a name="line108"></a>/**
<a name="line109"></a> * Returns a date in full date format, e.g. Tuesday, March 24, 2009.
<a name="line110"></a> * @param {Date} date The date object.
<a name="line111"></a> * @return {string} The formatted string.
<a name="line112"></a> * @private
<a name="line113"></a> */
<a name="line114"></a>goog.date.relative.formatFullDate_ = function(date) {
<a name="line115"></a>  if (!goog.date.relative.fullDateFormatter_) {
<a name="line116"></a>    goog.date.relative.fullDateFormatter_ = new goog.i18n.DateTimeFormat(
<a name="line117"></a>        goog.i18n.DateTimeFormat.Format.FULL_DATE);
<a name="line118"></a>  }
<a name="line119"></a>  return goog.date.relative.fullDateFormatter_.format(date);
<a name="line120"></a>};
<a name="line121"></a>
<a name="line122"></a>
<a name="line123"></a>/**
<a name="line124"></a> * Accepts a timestamp in milliseconds and outputs a relative time in the form
<a name="line125"></a> * of &quot;1 hour ago&quot;, &quot;1 day ago&quot;, &quot;in 1 hour&quot;, &quot;in 2 days&quot; etc.  If the date
<a name="line126"></a> * delta is over 2 weeks, then the output string will be empty.
<a name="line127"></a> * @param {number} dateMs Date in milliseconds.
<a name="line128"></a> * @return {string} The formatted date.
<a name="line129"></a> */
<a name="line130"></a>goog.date.relative.format = function(dateMs) {
<a name="line131"></a>
<a name="line132"></a>  var now = goog.now();
<a name="line133"></a>  var delta = Math.floor((now - dateMs) / goog.date.relative.MINUTE_MS_);
<a name="line134"></a>
<a name="line135"></a>  var future = false;
<a name="line136"></a>
<a name="line137"></a>  if (delta &lt; 0) {
<a name="line138"></a>    future = true;
<a name="line139"></a>    delta *= -1;
<a name="line140"></a>  }
<a name="line141"></a>
<a name="line142"></a>  if (delta &lt; 60) { // Minutes.
<a name="line143"></a>    return goog.date.relative.getMessage_(
<a name="line144"></a>        delta, future, goog.date.relative.Unit_.MINUTES);
<a name="line145"></a>
<a name="line146"></a>  } else {
<a name="line147"></a>    delta = Math.floor(delta / 60);
<a name="line148"></a>    if (delta &lt; 24) { // Hours.
<a name="line149"></a>      return goog.date.relative.getMessage_(
<a name="line150"></a>          delta, future, goog.date.relative.Unit_.HOURS);
<a name="line151"></a>
<a name="line152"></a>    } else {
<a name="line153"></a>      // Timezone offset is in minutes.  We pass goog.now so that we can easily
<a name="line154"></a>      // unit test this, the JSCompiler will optimize it away for us.
<a name="line155"></a>      var offset = new Date(goog.now()).getTimezoneOffset() *
<a name="line156"></a>          goog.date.relative.MINUTE_MS_;
<a name="line157"></a>
<a name="line158"></a>      // Convert to days ago.
<a name="line159"></a>      delta = Math.floor((now + offset) / goog.date.relative.DAY_MS_) -
<a name="line160"></a>              Math.floor((dateMs + offset) / goog.date.relative.DAY_MS_);
<a name="line161"></a>
<a name="line162"></a>      if (future) {
<a name="line163"></a>        delta *= -1;
<a name="line164"></a>      }
<a name="line165"></a>
<a name="line166"></a>      // Uses days for less than 2-weeks.
<a name="line167"></a>      if (delta &lt; 14) {
<a name="line168"></a>        return goog.date.relative.getMessage_(
<a name="line169"></a>            delta, future, goog.date.relative.Unit_.DAYS);
<a name="line170"></a>
<a name="line171"></a>      } else {
<a name="line172"></a>        // For messages older than 2 weeks do not show anything.  The client
<a name="line173"></a>        // should decide the date format to show.
<a name="line174"></a>        return &#39;&#39;;
<a name="line175"></a>      }
<a name="line176"></a>    }
<a name="line177"></a>  }
<a name="line178"></a>};
<a name="line179"></a>
<a name="line180"></a>
<a name="line181"></a>/**
<a name="line182"></a> * Accepts a timestamp in milliseconds and outputs a relative time in the form
<a name="line183"></a> * of &quot;1 hour ago&quot;, &quot;1 day ago&quot;.  All future times will be returned as 0 minutes
<a name="line184"></a> * ago.
<a name="line185"></a> *
<a name="line186"></a> * This is provided for compatibility with users of the previous incarnation of
<a name="line187"></a> * the above {@see #format} method who relied on it protecting against
<a name="line188"></a> * future dates.
<a name="line189"></a> *
<a name="line190"></a> * @param {number} dateMs Date in milliseconds.
<a name="line191"></a> * @return {string} The formatted date.
<a name="line192"></a> */
<a name="line193"></a>goog.date.relative.formatPast = function(dateMs) {
<a name="line194"></a>  var now = goog.now();
<a name="line195"></a>  if (now &lt; dateMs) {
<a name="line196"></a>    dateMs = now;
<a name="line197"></a>  }
<a name="line198"></a>  return goog.date.relative.format(dateMs);
<a name="line199"></a>};
<a name="line200"></a>
<a name="line201"></a>
<a name="line202"></a>/**
<a name="line203"></a> * Accepts a timestamp in milliseconds and outputs a relative day. i.e. &quot;Today&quot;,
<a name="line204"></a> * &quot;Yesterday&quot; or &quot;Sept 15&quot;.
<a name="line205"></a> *
<a name="line206"></a> * @param {number} dateMs Date in milliseconds.
<a name="line207"></a> * @return {string} The formatted date.
<a name="line208"></a> */
<a name="line209"></a>goog.date.relative.formatDay = function(dateMs) {
<a name="line210"></a>  var message;
<a name="line211"></a>  var today = new Date(goog.now());
<a name="line212"></a>
<a name="line213"></a>  today.setHours(0);
<a name="line214"></a>  today.setMinutes(0);
<a name="line215"></a>  today.setSeconds(0);
<a name="line216"></a>  today.setMilliseconds(0);
<a name="line217"></a>
<a name="line218"></a>  var yesterday = new Date(today.getTime() - goog.date.relative.DAY_MS_);
<a name="line219"></a>  if (today.getTime() &lt; dateMs) {
<a name="line220"></a>    /** @desc Today. */
<a name="line221"></a>    var MSG_TODAY = goog.getMsg(&#39;Today&#39;);
<a name="line222"></a>    message = MSG_TODAY;
<a name="line223"></a>  } else if (yesterday.getTime() &lt; dateMs) {
<a name="line224"></a>    /** @desc Yesterday. */
<a name="line225"></a>    var MSG_YESTERDAY = goog.getMsg(&#39;Yesterday&#39;);
<a name="line226"></a>    message = MSG_YESTERDAY;
<a name="line227"></a>  } else {
<a name="line228"></a>    message = goog.date.relative.formatMonth_(new Date(dateMs));
<a name="line229"></a>  }
<a name="line230"></a>  return message;
<a name="line231"></a>};
<a name="line232"></a>
<a name="line233"></a>
<a name="line234"></a>/**
<a name="line235"></a> * Formats a date, adding the relative date in parenthesis.  If the date is less
<a name="line236"></a> * than 24 hours then the time will be printed, otherwise the full-date will be
<a name="line237"></a> * used.  Examples:
<a name="line238"></a> *   2:20 PM (1 minute ago)
<a name="line239"></a> *   Monday, February 27, 2009 (4 days ago)
<a name="line240"></a> *   Tuesday, March 20, 2005    // Too long ago for a relative date.
<a name="line241"></a> *
<a name="line242"></a> * @param {Date} date A date object.
<a name="line243"></a> * @param {string} opt_shortTimeMsg An optional short time message can be
<a name="line244"></a> *     provided if available, so that it&#39;s not recalculated in this function.
<a name="line245"></a> * @param {string} opt_fullDateMsg An optional date message can be
<a name="line246"></a> *     provided if available, so that it&#39;s not recalculated in this function.
<a name="line247"></a> * @return {string} The date string in the above form.
<a name="line248"></a> */
<a name="line249"></a>goog.date.relative.getDateString = function(
<a name="line250"></a>    date, opt_shortTimeMsg, opt_fullDateMsg) {
<a name="line251"></a>  return goog.date.relative.getDateString_(
<a name="line252"></a>      date, goog.date.relative.format, opt_shortTimeMsg, opt_fullDateMsg)
<a name="line253"></a>};
<a name="line254"></a>
<a name="line255"></a>
<a name="line256"></a>/**
<a name="line257"></a> * Formats a date, adding the relative date in parenthesis.   Functions the same
<a name="line258"></a> * as #getDateString but ensures that the date is always seen to be in the past.
<a name="line259"></a> * If the date is in the future, it will be shown as 0 minutes ago.
<a name="line260"></a> *
<a name="line261"></a> * This is provided for compatibility with users of the previous incarnation of
<a name="line262"></a> * the above {@see #getDateString} method who relied on it protecting against
<a name="line263"></a> * future dates.
<a name="line264"></a> *
<a name="line265"></a> * @param {Date} date A timestamp or date object.
<a name="line266"></a> * @param {string} opt_shortTimeMsg An optional short time message can be
<a name="line267"></a> *     provided if available, so that it&#39;s not recalculated in this function.
<a name="line268"></a> * @param {string} opt_fullDateMsg An optional date message can be
<a name="line269"></a> *     provided if available, so that it&#39;s not recalculated in this function.
<a name="line270"></a> * @return {string} The date string in the above form.
<a name="line271"></a> */
<a name="line272"></a>goog.date.relative.getPastDateString = function(
<a name="line273"></a>    date, opt_shortTimeMsg, opt_fullDateMsg) {
<a name="line274"></a>  return goog.date.relative.getDateString_(
<a name="line275"></a>      date, goog.date.relative.formatPast, opt_shortTimeMsg, opt_fullDateMsg)
<a name="line276"></a>};
<a name="line277"></a>
<a name="line278"></a>
<a name="line279"></a>/**
<a name="line280"></a> * Formats a date, adding the relative date in parenthesis.  If the date is less
<a name="line281"></a> * than 24 hours then the time will be printed, otherwise the full-date will be
<a name="line282"></a> * used.  Examples:
<a name="line283"></a> *   2:20 PM (1 minute ago)
<a name="line284"></a> *   Monday, February 27, 2009 (4 days ago)
<a name="line285"></a> *   Tuesday, March 20, 2005    // Too long ago for a relative date.
<a name="line286"></a> *
<a name="line287"></a> * @param {Date} date A timestamp or date object.
<a name="line288"></a> * @param {function(number) : string} relativeFormatter Function to use when
<a name="line289"></a> *     formatting the relative date.
<a name="line290"></a> * @param {string} opt_shortTimeMsg An optional short time message can be
<a name="line291"></a> *     provided if available, so that it&#39;s not recalculated in this function.
<a name="line292"></a> * @param {string} opt_fullDateMsg An optional date message can be
<a name="line293"></a> *     provided if available, so that it&#39;s not recalculated in this function.
<a name="line294"></a> * @return {string} The date string in the above form.
<a name="line295"></a> * @private
<a name="line296"></a> */
<a name="line297"></a>goog.date.relative.getDateString_ = function(
<a name="line298"></a>    date, relativeFormatter, opt_shortTimeMsg, opt_fullDateMsg) {
<a name="line299"></a>  var dateMs = date.getTime();
<a name="line300"></a>
<a name="line301"></a>  var relativeDate = relativeFormatter(dateMs);
<a name="line302"></a>
<a name="line303"></a>  if (relativeDate) {
<a name="line304"></a>    relativeDate = &#39; (&#39; + relativeDate + &#39;)&#39;;
<a name="line305"></a>  }
<a name="line306"></a>
<a name="line307"></a>  var delta = Math.floor((goog.now() - dateMs) / goog.date.relative.MINUTE_MS_);
<a name="line308"></a>  if (delta &lt; 60 * 24) {
<a name="line309"></a>    return (opt_shortTimeMsg || goog.date.relative.formatShortTime_(date)) +
<a name="line310"></a>        relativeDate;
<a name="line311"></a>  } else {
<a name="line312"></a>    return (opt_fullDateMsg || goog.date.relative.formatFullDate_(date)) +
<a name="line313"></a>        relativeDate;
<a name="line314"></a>  }
<a name="line315"></a>};
<a name="line316"></a>
<a name="line317"></a>
<a name="line318"></a>/**
<a name="line319"></a> * Gets a localized relative date string for a given delta and unit.
<a name="line320"></a> * @param {number} delta Number of minutes/hours/days.
<a name="line321"></a> * @param {boolean} future Whether the delta is in the future.
<a name="line322"></a> * @param {goog.date.relative.Unit_} unit The units the delta is in.
<a name="line323"></a> * @return {string} The message.
<a name="line324"></a> * @private
<a name="line325"></a> */
<a name="line326"></a>goog.date.relative.getMessage_ = function(delta, future, unit) {
<a name="line327"></a>  if (!future &amp;&amp; unit == goog.date.relative.Unit_.MINUTES) {
<a name="line328"></a>    /**
<a name="line329"></a>     * @desc Relative date indicating how many minutes ago something happened
<a name="line330"></a>     * (singular).
<a name="line331"></a>     */
<a name="line332"></a>    var MSG_MINUTES_AGO_SINGULAR =
<a name="line333"></a>        goog.getMsg(&#39;{$num} minute ago&#39;, {&#39;num&#39; : delta});
<a name="line334"></a>
<a name="line335"></a>      /**
<a name="line336"></a>       * @desc Relative date indicating how many minutes ago something happened
<a name="line337"></a>       * (plural).
<a name="line338"></a>       */
<a name="line339"></a>    var MSG_MINUTES_AGO_PLURAL =
<a name="line340"></a>        goog.getMsg(&#39;{$num} minutes ago&#39;, {&#39;num&#39; : delta});
<a name="line341"></a>
<a name="line342"></a>    return delta == 1 ? MSG_MINUTES_AGO_SINGULAR : MSG_MINUTES_AGO_PLURAL;
<a name="line343"></a>
<a name="line344"></a>  } else if (future &amp;&amp; unit == goog.date.relative.Unit_.MINUTES) {
<a name="line345"></a>    /**
<a name="line346"></a>     * @desc Relative date indicating in how many minutes something happens
<a name="line347"></a>     * (singular).
<a name="line348"></a>     */
<a name="line349"></a>    var MSG_IN_MINUTES_SINGULAR =
<a name="line350"></a>        goog.getMsg(&#39;in {$num} minute&#39;, {&#39;num&#39; : delta});
<a name="line351"></a>
<a name="line352"></a>      /**
<a name="line353"></a>       * @desc Relative date indicating in how many minutes something happens
<a name="line354"></a>       * (plural).
<a name="line355"></a>       */
<a name="line356"></a>    var MSG_IN_MINUTES_PLURAL =
<a name="line357"></a>        goog.getMsg(&#39;in {$num} minutes&#39;, {&#39;num&#39; : delta});
<a name="line358"></a>
<a name="line359"></a>    return delta == 1 ? MSG_IN_MINUTES_SINGULAR : MSG_IN_MINUTES_PLURAL;
<a name="line360"></a>
<a name="line361"></a>  } else if (!future &amp;&amp; unit == goog.date.relative.Unit_.HOURS) {
<a name="line362"></a>    /**
<a name="line363"></a>     * @desc Relative date indicating how many hours ago something happened
<a name="line364"></a>     * (singular).
<a name="line365"></a>     */
<a name="line366"></a>    var MSG_HOURS_AGO_SINGULAR =
<a name="line367"></a>        goog.getMsg(&#39;{$num} hour ago&#39;, {&#39;num&#39; : delta});
<a name="line368"></a>
<a name="line369"></a>    /**
<a name="line370"></a>     * @desc Relative date indicating how many hours ago something happened
<a name="line371"></a>     * (plural).
<a name="line372"></a>     */
<a name="line373"></a>    var MSG_HOURS_AGO_PLURAL = goog.getMsg(&#39;{$num} hours ago&#39;, {&#39;num&#39; : delta});
<a name="line374"></a>
<a name="line375"></a>    return delta == 1 ? MSG_HOURS_AGO_SINGULAR : MSG_HOURS_AGO_PLURAL;
<a name="line376"></a>
<a name="line377"></a>  } else if (future &amp;&amp; unit == goog.date.relative.Unit_.HOURS) {
<a name="line378"></a>    /**
<a name="line379"></a>     * @desc Relative date indicating in how many hours something happens
<a name="line380"></a>     * (singular).
<a name="line381"></a>     */
<a name="line382"></a>    var MSG_IN_HOURS_SINGULAR = goog.getMsg(&#39;in {$num} hour&#39;, {&#39;num&#39; : delta});
<a name="line383"></a>
<a name="line384"></a>    /**
<a name="line385"></a>     * @desc Relative date indicating in how many hours something happens
<a name="line386"></a>     * (plural).
<a name="line387"></a>     */
<a name="line388"></a>    var MSG_IN_HOURS_PLURAL = goog.getMsg(&#39;in {$num} hours&#39;, {&#39;num&#39; : delta});
<a name="line389"></a>
<a name="line390"></a>    return delta == 1 ? MSG_IN_HOURS_SINGULAR : MSG_IN_HOURS_PLURAL;
<a name="line391"></a>
<a name="line392"></a>  } else if (!future &amp;&amp; unit == goog.date.relative.Unit_.DAYS) {
<a name="line393"></a>    /**
<a name="line394"></a>     * @desc Relative date indicating how many days ago something happened
<a name="line395"></a>     * (singular).
<a name="line396"></a>     */
<a name="line397"></a>    var MSG_DAYS_AGO_SINGULAR = goog.getMsg(&#39;{$num} day ago&#39;, {&#39;num&#39; : delta});
<a name="line398"></a>
<a name="line399"></a>    /**
<a name="line400"></a>     * @desc Relative date indicating how many days ago something happened
<a name="line401"></a>     * (plural).
<a name="line402"></a>     */
<a name="line403"></a>    var MSG_DAYS_AGO_PLURAL = goog.getMsg(&#39;{$num} days ago&#39;, {&#39;num&#39; : delta});
<a name="line404"></a>
<a name="line405"></a>    return delta == 1 ? MSG_DAYS_AGO_SINGULAR : MSG_DAYS_AGO_PLURAL;
<a name="line406"></a>
<a name="line407"></a>  } else if (future &amp;&amp; unit == goog.date.relative.Unit_.DAYS) {
<a name="line408"></a>    /**
<a name="line409"></a>     * @desc Relative date indicating in how many days something happens
<a name="line410"></a>     * (singular).
<a name="line411"></a>     */
<a name="line412"></a>    var MSG_IN_DAYS_SINGULAR = goog.getMsg(&#39;in {$num} day&#39;, {&#39;num&#39; : delta});
<a name="line413"></a>
<a name="line414"></a>    /**
<a name="line415"></a>     * @desc Relative date indicating in how many days something happens
<a name="line416"></a>     * (plural).
<a name="line417"></a>     */
<a name="line418"></a>    var MSG_IN_DAYS_PLURAL = goog.getMsg(&#39;in {$num} days&#39;, {&#39;num&#39; : delta});
<a name="line419"></a>
<a name="line420"></a>    return delta == 1 ? MSG_IN_DAYS_SINGULAR : MSG_IN_DAYS_PLURAL;
<a name="line421"></a>
<a name="line422"></a>  } else {
<a name="line423"></a>    return &#39;&#39;;
<a name="line424"></a>  }
<a name="line425"></a>};
</pre>


</body>
</html>
